package pub.wkq.observer.weather.impl;

import pub.wkq.observer.weather.DisplayElement;
import pub.wkq.observer.weather.Observer;

public class CurrentConditionsDisplay implements DisplayElement , Observer {
    private float temperature;
    private float humidity;
    private WeatherData weatherData;

    public CurrentConditionsDisplay(WeatherData weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("Current condition : " + temperature + "F degrees and " + humidity + "% humidity");
    }

    @Override
    public void update() {
        this.temperature = weatherData.getTemperature();
        this.humidity = weatherData.getHumidity();
        this.display();
    }
}
